package main

import (
	"gateway/service"
	"github.com/gin-gonic/gin"
	"log"
	"net/http"
)

func main() {
	route := gin.Default()
	route.GET("/", func(ct *gin.Context) {
		ct.JSON(http.StatusOK, gin.H{"/login": "localhost:16010/login",
			"/register":                   "localhost:16010/register",
			"/admin/login":                "localhost:16010/admin/login",
			"/admin/register":             "localhost:16010/admin/register",
			"/admin/block":                "localhost:16010/admin/block",
			"/user/update":                "localhost:16010/user/update",
			"/user/querydata":             "localhost:16010/user/querydata",
			"/admin/querydata":            "localhost:16010/admin/querydata",
			"/chat/create":                "localhost:16010/chat/create",
			"/chat/join":                  "localhost:16010/chat/join",
			"/chat/add":                   "localhost:16010/chat/add",
			"/chat/quit":                  "localhost:16010/chat/quit",
			"/chat/query":                 "localhost:16010/chat/query",
			"/chat/send":                  "localhost:16010/chat/send",
			"/rankings/score":             "localhost:16010/rankings/score",
			"/chessgame/create":           "localhost:16010/chessgame/create",
			"/chessgame/join":             "localhost:16010/chessgame/join",
			"/chessgame/play":             "localhost:16010/chessgame/play",
			"/chessgame/showroomlist":     "localhost:16010/chessgame/showroomlist",
			"/chessgame/showcombatrecord": "localhost:16010/chessgame/showcombatrecord",
		})
	})
	route.POST("/login", func(ct *gin.Context) {
		service.UserLogin(ct)
	})
	route.POST("/register", func(ct *gin.Context) {
		service.UserRegister(ct)
	})
	route.POST("/admin/login", func(ct *gin.Context) {
		service.AdminLogin(ct)
	})
	route.POST("/admin/register", func(ct *gin.Context) {
		service.AdminRegister(ct)
	})
	route.POST("/admin/block", func(ct *gin.Context) {
		service.BlockUser(ct)
	})
	route.POST("/user/update", func(ct *gin.Context) {
		service.UserUpdate(ct)
	})
	route.POST("/user/querydata", func(ct *gin.Context) {
		service.UserQuery(ct)
	})
	route.POST("/admin/querydata", func(ct *gin.Context) {
		service.AdminQuery(ct)
	})
	route.POST("/chat/create", func(ct *gin.Context) {
		service.CreateRoom(ct)
	})
	route.POST("/chat/join", func(ct *gin.Context) {
		service.JoinRoom(ct)
	})
	route.POST("/chat/add", func(ct *gin.Context) {
		service.AddUser(ct)
	})
	route.POST("/chat/quit", func(ct *gin.Context) {
		service.QuitRoom(ct)
	})
	route.POST("/chat/query", func(ct *gin.Context) {
		service.QueryMessage(ct)
	})
	route.POST("/chat/send", func(ct *gin.Context) {
		service.SentMessage(ct)
	})
	route.POST("/rankings/score", func(ct *gin.Context) {
		service.GetRankingList(ct)
	})
	route.POST("/chessgame/create", func(ct *gin.Context) {
		service.CreateGameRoom(ct)
	})
	route.POST("/chessgame/join", func(ct *gin.Context) {
		service.JoinGameRoom(ct)
	})
	route.POST("/chessgame/play", func(ct *gin.Context) {
		service.PlayGame(ct)
	})
	route.POST("/chessgame/showroomlist", func(ct *gin.Context) {
		service.ShowGameRoom(ct)
	})
	route.POST("/chessgame/showcombatrecord", func(ct *gin.Context) {
		service.ShowGameCombatRecord(ct)
	})
	err := route.Run(":16010")
	if err != nil {
		log.Println(err.Error())
		return
	}
}
